package com.demo.service.impl;


import com.demo.domain.CtFarm;
import com.demo.mapper.CtFarmDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CtFarm)表服务实现类
 *
 * @author makejava
 * @since 2021-07-07 09:39:48
 */
@Service
public class CtFarmServiceImpl {
    @Resource
    private CtFarmDao ctFarmDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */

    public CtFarm queryById(Integer id) {
        return this.ctFarmDao.queryById(id);
    }

    /**
     * 查询多条数据
     * @return 对象列表
     */

    public List<CtFarm> queryAllByLimit() {
        return this.ctFarmDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param ctFarm 实例对象
     * @return 实例对象
     */

    public CtFarm insert(CtFarm ctFarm) {
        this.ctFarmDao.insert(ctFarm);
        return ctFarm;
    }

    /**
     * 修改数据
     *
     * @param ctFarm 实例对象
     * @return 实例对象
     */

    public CtFarm update(CtFarm ctFarm) {
        this.ctFarmDao.update(ctFarm);
        return this.queryById(ctFarm.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */

    public boolean deleteById(Integer id) {
        return this.ctFarmDao.deleteById(id) > 0;
    }
}